package com.jprocms.module.cms.api;

import com.jpro.framework.common.pojo.CommonResult;
import com.jprocms.module.cms.api.dto.GlobalConfigRespVO;
import com.jprocms.module.cms.convert.globalconfig.GlobalConfigConvert;
import com.jprocms.module.cms.dal.dataobject.globalconfig.GlobalConfigDO;
import com.jprocms.module.cms.service.globalconfig.GlobalConfigService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static com.jpro.framework.common.pojo.CommonResult.success;

@RestController // 提供 RESTful API 接口，给 Feign 调用

@Validated
public class GlobalConfigApiImpl implements GlobalConfigApi {
    @Resource
    private GlobalConfigService globalConfigService;

    @Override
    public CommonResult<GlobalConfigRespVO> getGlobalConfig() {
        GlobalConfigDO globalConfig = globalConfigService.getDefGlobalConfig();
        return success(GlobalConfigConvert.INSTANCE.convert(globalConfig));
    }
}
